//
//  UIViewController+CustomNavigation.m
//  BigTv
//
//  Created by huliang on 12-11-15.
//  Copyright (c) 2012年 huliang. All rights reserved.
//

#import "UIViewController+CustomNavigation.h"

#import "KY_AppDelegate.h"
@implementation UIViewController(Custom)

-(void)dealloc{
    
    [super dealloc];
    
}
//ViewConroller.m 文件

-(void)showBackBtn{
    
       UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"leftbtn.png"] forState:UIControlStateNormal];
    [backBtn setFrame:CGRectMake(0, 0, 53 ,23)];
    [backBtn addTarget:self action:@selector(backBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] initWithCustomView:backBtn] autorelease];
    self.navigationItem.leftBarButtonItem = backItem;
}


-(void)backBtnClicked:(id)sender{
    
    if( [self.navigationController popViewControllerAnimated:YES]  == nil){
        [self dismissModalViewControllerAnimated:YES];
    }
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return  UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}


@end
